import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },{
    path:'/nav',
    name:'nav',
    component:()=>import('../views/Nav.vue')

  },{
    path:'/layout',
    name:'layout',
    component:()=>import('../views/Layout.vue')
  },{
    path:'/components',
    name:'components',
    redirect:'/components/index',  //路由重定向属性
    component:()=>import('../views/Components.vue'),
    children: [
        {
          path:'index',  //耳机路由不以斜杠开头
          name:'index',
          component:()=>import('../views/Index.vue')
        },{
          path:'form',
          name:'form',
          component:()=>import('../views/Form.vue')
        },{
          path:'table',
          name:'table',
          component:()=>import('../views/Table.vue')
        },{
          path:'layout',
          name:'layout',
          component:()=>import('../views/Layout.vue')
        },
      ]
  }
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
